package com.seata.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.seata.mapper.StorageMapper;
import com.seata.model.Storage;
import com.seata.service.StorageService;
import io.seata.core.context.RootContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: TongRui乀
 * @Date: 2019-12-05 17:11
 * @description：
 */
@Service
public class StorageServiceImpl extends ServiceImpl<StorageMapper, Storage> implements StorageService {

    @Autowired
    private StorageMapper storageMapper;

    @Override
    public Integer decreaseStorage(Storage storage) {

        System.err.println("全局事务ID：" + RootContext.getXID());

        try {
            return this.storageMapper.updateById(storage);
        }catch (Exception e){
            e.printStackTrace();
            return 500;
        }
    }
}
